package com.lxyk.mapper;

import com.lxyk.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserMapper {
    //查询所有
        @Select("select * from user")
        List<User> findAll();
    //新增
    @Insert("insert into user values(null,#{name},#{gender},#{age},#{address},#{art},#{email})")
    Integer add(User user);

    //根据id删除
    @Delete("delete from user where id = #{id}")
    Integer deleteById(Integer id);

    //根据id查询
    @Select("select * from user where id = #{id}")
    User findById(Integer id);

    //修改
    @Update("update user set name=#{name},gender=#{gender},age=#{age}," +
            "address=#{address},art=#{art},email=#{email} where id = #{id}")
    Integer update(User user);

    //根据条件动态查询
    List<User> findByCode(User user);
}
